var BusinessMaterialTable = function () {
  var template = /* html */ `
    <div class="business-material-table">
      <div class="business-material-table-title">物料信息</div>
      <el-table fit stripe border :data="materials">
        <el-table-column label="物料类型" prop="materialType" min-width="130px" header-align="center"></el-table-column>
        <el-table-column :resizable="false" label="仓位" min-width="120px" header-align="center">
          <template slot-scope="scope">
            <span>{{i18n.getMsg('bomBusiness.defaultWarehouse.'+scope.row.materialFactory)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="物料名称" prop="materialName" min-width="120px" header-align="center"></el-table-column>
        <el-table-column label="物料规格" prop="materialModel" min-width="120px" header-align="center"></el-table-column>
        <el-table-column label="供应商" prop="materialProviderName" min-width="120px" header-align="center"></el-table-column>
        <el-table-column label="色号" prop="materialColor" min-width="120px" header-align="center"></el-table-column>
        <el-table-column label="颜色描述" prop="materialColorDescription" min-width="120px" header-align="center"></el-table-column>
        <el-table-column :resizable="false" label="开料方式" prop="materialKlfs" min-width="100px" align="center"></el-table-column>
        <el-table-column :resizable="false" label="难易度" min-width="100px" align="center">
          <template slot-scope="scope">
            <span>{{getDifficultRate(scope.row.materialDifficultLevelRate)}}%</span>
          </template>
        </el-table-column>
        <el-table-column :resizable="false" label="每条料可开数" prop="materialMtlktTotal" min-width="100px" align="center"></el-table-column>
        <el-table-column label="投料数比例" min-width="120px" align="center">
          <template slot-scope="scope">
            <span>1 : {{scope.row.materialFeedTotalRate}}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  `;

  return {
    props: {
      materials: {
        type: Array,
        required: true
      }
    },

    data: function () {
      return {};
    },

    methods: {
      getDifficultRate: function (rate) {
        rate *= 100;
        return _.round(rate, 2);
      }
    },

    template: template
  };
}();
